#import "DDLoginInput.h"
@interface DDLoginInput ()<JTWTextFieldDelegate>
@property (nonatomic, strong) UIView *line;
@end
@implementation DDLoginInput
- (instancetype)init
{
    self = [super init];
    if (self)
    {
        self.backgroundColor = [UIColor whiteColor];
        self.line.backgroundColor = CELL_LINE_COLOR;
    }
    return self;
}
- (UIView *)line
{
    if (!_line)
    {
       _line = [[UIView alloc] init];
        [self addSubview:_line];
        _line.c_centerY.c_equal(self);
        _line.c_left.c_equal(self).with.coffset(GAP);
        _line.c_right.c_equal(self).with.coffset(-GAP);
        _line.c_height.c_equal(1);
    }
    return _line;
}
- (DDTextField *)nameTF
{
    if (!_nameTF)
    {
        _nameTF = [[DDTextField alloc] init];
        _nameTF.type = JTWTextFieldTypeAccountList;
        _nameTF.returnKeyType = UIReturnKeyNext;
        _nameTF.customDelegate = self;
        [self addSubview:_nameTF];
        _nameTF.c_top.c_equal(self);
        _nameTF.c_left.c_equal(self);
        _nameTF.c_right.c_equal(self);
        _nameTF.c_height.c_equal(TEXTFILDHEIGHT);
    }
    return _nameTF;
}
- (DDTextField *)passTF
{
    if (!_passTF)
    {
        _passTF = [[DDTextField alloc] init];
        _passTF.type = JTWTextFieldTypePassword;
        _passTF.customDelegate = self;
        [self addSubview:_passTF];
        _passTF.c_top.c_equal(self.nameTF.c_bottom);
        _passTF.c_left.c_equal(self);
        _passTF.c_right.c_equal(self);
        _passTF.c_height.c_equal(TEXTFILDHEIGHT);
    }
    return _passTF;
}
#pragma mark - YJDTextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if (textField.returnKeyType == UIReturnKeyNext && [textField isEqual:self.nameTF])
    {
        [self.passTF becomeFirstResponder];
        return NO;
    }
    return YES;
}
@end
